﻿using System;
using System.Collections.Generic;

public partial class ContractsPrintForm_Control : System.Web.UI.UserControl
{
    ServerObject mServerObject = null;
    bool mAutentificatedUser = false;

    string mContractID = string.Empty;

    public string ContractID
    {
        get { return mContractID; }
        set { mContractID = value; }
    }

    public string PrintAreaID
    {
        get { return startUp_PrintForm.ClientID; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {       
    }

    public void PrepareViewContract(Credits.DataObjects.LoanObject selectedContract, List<Credits.DataObjects.Fidejusor> FutjiList)
    {
        try
        {
            startUp_nrContractLabel.Text = selectedContract.ContractCode.ToString();
            startUp_specialContractStartDate.Text = "Din: " + selectedContract.ContractSpecificStartDate;
            startUp_clientFirstLastNameLabel.Text = selectedContract.ClientFirstLastName;
            startUp_clientRaionLabel.Text = selectedContract.ClientRaion;
            startUp_clientLocalitateaLabel.Text = selectedContract.ClientLocalitatea;
            startUp_clientStradaAdresaLabel.Text = selectedContract.ClientStradaAdresa;
            startUp_clientPersonalID.Text = selectedContract.ClientPersonalID;
            startUp_clientBirthDateLabel.Text = selectedContract.ClientBirthDate.ToString(Constants.Constants.ISODateBackwardDotsFormat);
            startUp_loanAmountLabel.Text = selectedContract.ContractAmount.ToString();
            startUp_loanAmountInWordsLabel.Text = selectedContract.ContractAmountInWords;
            startUp_LoanScopeLabel.Text = selectedContract.LoanScope;

            string contractFidejusoriList = string.Empty;
            for (int i = 0; i < FutjiList.Count; i++)
            {
                contractFidejusoriList += Crypt.Utils.GetNexLetter('b', i) + ") Contract de fidejusiune nr. <b> " + FutjiList[i].ContractCode + "-" + FutjiList[i].OrderID + " cu " + FutjiList[i].FidejusorFirstLastName + " (IDNP/IDNO " + FutjiList[i].FidejusorIDNO + ") </b> <br />  ";
            }

            contractPrintForm_FidejusorDIV.InnerHtml = contractFidejusoriList;
            loanEndDateLabel.Text = selectedContract.ContractSpecificEndDate;
            startUp_loanPercentLabel.Text = selectedContract.ContrcatPercent.ToString();
            startUp_loanPercetInWordsLabel.Text = selectedContract.ContrcatPercentInWords;
            startUp_endClintFirstlastNameLabel.Text = selectedContract.ClientFirstLastName;
            startUp_endClientLocalitateaLabel.Text = selectedContract.ClientLocalitatea;
            startUp_endClientRaionLabel.Text = selectedContract.ClientRaion;
            startUp_endClientPersonalIDLabel.Text = selectedContract.ClientPersonalID;
            startUp_endClientBankFullNameLabel.Text = selectedContract.BankFullName;
            startUp_endCodBancaLabel.Text = selectedContract.CodulBancii;
            startUp_endContInBancaLabel.Text = selectedContract.ContBancar;
            startUp_endClientTelefonLabel.Text = selectedContract.ClientTelefon;
            startUp_endClientFirstLastNameLabel2.Text = selectedContract.ClientFirstLastName;
        }
        catch (Exception ex)
        {
            Utils.InfoText(this.Page, "Atentie! Eroare in sistem!", ex.Message);
        }
    }
}